package com.jmu.Shape;

import java.util.Objects;

//圆的类
public class Circle extends Shape{
    //设置半径
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    @Override
    public double getPerimeter() {
        return 2.0 * PI * radius;
    }

    @Override
    public double getArea() {
        double result = PI * radius * radius;
        return result;
    }

    //getter/setter方法

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Circle circle = (Circle) o;
        return Double.compare(circle.radius, radius) == 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(radius);
    }
}

